package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Controller
public class PageController {

    @Autowired
    private PageService pageService;

    @GetMapping("/item/{spuId}.html")
    public String toItemPage(Model model, @PathVariable("spuId") Long id){
        Map<String, Object> itemInfo = pageService.itemInfo(id);
        model.addAllAttributes(itemInfo);
        return "item";
    }
    @PostMapping("/evaluate")
    public ResponseEntity<Void>evaluate(@RequestParam("orderId") Long orderId, @RequestParam("evaluate") String evaluate){
        System.out.println(111);
        return ResponseEntity.status(HttpStatus.CREATED).build();
    }

}
